//
//  TableViewCell.m
//  Estate
//
//  Created by heyong on 16/6/8.
//  Copyright © 2016年 ttsx. All rights reserved.
//

#import "B_LouCell.h"

@implementation B_LouCell

- (void)setIsEdit:(BOOL)isEdit{
    if(isEdit){
        self.lou.delegate=self;
        self.ceng.delegate=self;
        self.duan.delegate=self;
        self.adderss.delegate=self;
//        self.lou.keyboardType=UIKeyboardTypeNumberPad;
//        self.ceng.keyboardType=UIKeyboardTypeNumberPad;
//        self.duan.keyboardType=UIKeyboardTypeNumberPad;
//        self.adderss.keyboardType=UIKeyboardTypeDefault;
    }else{
        self.lou.userInteractionEnabled=NO;
        self.ceng.userInteractionEnabled=NO;
        self.duan.userInteractionEnabled=NO;
        self.adderss.userInteractionEnabled=NO;
    }

}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle=UITableViewCellSelectionStyleNone;
    self.one.textColor=UIColorFromRGB(0x797979);
    self.two.textColor=UIColorFromRGB(0x797979);
    self.three.textColor=UIColorFromRGB(0x797979);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)louChange:(UITextField *)sender {
    if(self.louChangeBlock){
        self.louChangeBlock(self.lou.text);
    }
}

- (IBAction)cengChange:(UITextField *)sender {
    if(self.cengChangeBlock){
        self.cengChangeBlock(self.ceng.text);
    }
}

- (IBAction)duanChange:(UITextField *)sender {
    if(self.duanChangeBlock){
        self.duanChangeBlock(self.duan.text);
    }
}

- (IBAction)addressChange:(UITextField *)sender {
    if(self.adderssChangeBlock){
        self.adderssChangeBlock(self.adderss.text);
    }
}

//设置分割线
- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect);
    //上分割线，
    CGContextSetStrokeColorWithColor(context,[UIColor colorWithRed:0.89 green:0.89 blue:0.90 alpha:1.00].CGColor); CGContextStrokeRect(context, CGRectMake(0, -1, rect.size.width , 1));
    //下分割线
    CGContextSetStrokeColorWithColor(context,[UIColor colorWithRed:0.89 green:0.89 blue:0.90 alpha:1.00].CGColor);
    CGContextStrokeRect(context, CGRectMake(0, rect.size.height+1, rect.size.width, 1));
}

#pragma mark UITextFieldDelegate

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_lou resignFirstResponder];
    [_ceng resignFirstResponder];
    [_duan resignFirstResponder];
    [_adderss resignFirstResponder];
    return  YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    //   限制苹果系统输入法  禁止输入表情
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }
 
    return YES;
}

@end
